package com.github.nuggets.controller;


import com.github.nuggets.entity.Account;
import com.github.nuggets.model.result.BaseResult;
import com.github.nuggets.model.vo.NuggetsAccountDetailVO;
import com.github.nuggets.service.AccountManagerService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description:
 * @author: wangsj
 * @date: 2022/3/17 1:05 下午
 */
@RestController
public class AccountController {

    @Autowired
    private AccountManagerService accountManagerService;

    @Operation(summary = "注册", description = "用户注册")
    @PostMapping("/account")
    public BaseResult<Boolean> registered(@RequestBody Account account) {

        return BaseResult.success(accountManagerService.registered(account));
    }

    @Operation(summary = "获取用户", description = "根据id获取用户详情信息")
    @GetMapping("/account/{accountId}")
    public BaseResult<NuggetsAccountDetailVO> getLoginAccount(@PathVariable("accountId") Long accountId) {
        return BaseResult.success(accountManagerService.findAccountDetails(accountId));
    }

    @Operation(summary = "获取用户", description = "根据id获取用户详情信息")
    @GetMapping("/account")
    public BaseResult<List<NuggetsAccountDetailVO>> getLoginAccount(@RequestParam String searchParam) {
        return BaseResult.success(accountManagerService.findAccounts(searchParam));
    }




}
